<?php

$limit = getInput("limit",10);
$offset = getInput("offset",0);



$reportContent = "";
$pagination = "";

$oneDayInSeconds = 60 * 60 * 24;

$from = getInput("from");

if ($from){
	if(!is_numeric($from)){
		$from = strtotime(ParseDateTimeToEn($from));
	}
}else{
	$from = time() - $oneDayInSeconds * 90;
}

$to = getInput("to");
if ($to){
	if(!is_numeric($to)){
		$to = strtotime(ParseDateTimeToEn($to));
	}
}else{
	$to = time() + ($oneDayInSeconds * 30);
}


$baseUrl = "reports.php?from=".$from."&to=".$to;

$benefits = new Benefit();

$result = $benefits->getTopRanked($from, $to + $oneDayInSeconds, null,null,$limit,$offset);
$count = $benefits->getTopRanked($from, $to + $oneDayInSeconds, null,null,$limit,$offset, true);
$reportContent = loadView("reports/rankedBenefits",array("entities"=>$result ,"from" => $from, "to" => $to));
$pagination = loadView("navigation/pagination", array("offset" => $offset, "limit" => $limit, "count" => $count, "baseUrl" => $baseUrl));



echo loadTemplate("top_menu", langEcho("reports"), array("main" => $reportContent . $pagination));
?>